package com.biz.primus.ms.oms.dao.po;

import com.biz.primus.model.oms.enums.OrderTimeoutCause;
import com.biz.primus.model.oms.enums.TimeoutHandleState;
import com.biz.primus.ms.base.jpa.po.BaseEntity;
import lombok.AccessLevel;
import lombok.Data;
import lombok.Getter;
import lombok.Setter;

import javax.persistence.*;
import java.time.LocalDateTime;

/**
 * 订单超时记录
 *
 * @author yanweijin
 */
@Data
@Entity
@Table(name="oms_timeout_record", indexes = {
        @Index(name="idx_state", columnList = "state"),
        @Index(name="idx_timeout_cause", columnList = "timeoutCause"),
        @Index(name="idx_expected_time", columnList = "expectedTime")
})
public class OrderTimeoutRecord extends BaseEntity{

    @Column(nullable = false, unique = true)
    private Long orderId;

    @Column(length = 50, nullable = false, unique = true)
    private String orderCode;

    /**
     * 处理状态
     */
    @Enumerated(EnumType.STRING)
    private TimeoutHandleState state = TimeoutHandleState.for_process;

    /**
     * 超时原因
     */
    @Enumerated(EnumType.STRING)
    private OrderTimeoutCause timeoutCause;

    /**
     * 处理结果
     */
    @Column(columnDefinition = "TEXT")
    private String handleResult;

    /**
     * 期望的时间(超过了这个时间,所以超时了)
     */
    private LocalDateTime expectedTime;

    /**
     * 处理人编号
     */
    @Column(length = 200)
    private String handler;

    /**
     * 处理时间
     */
    private LocalDateTime handleTime;

    @Version
    @Getter(AccessLevel.PRIVATE)
    @Setter(AccessLevel.PRIVATE)
    private long version;


}
